package code

import (
	"TaskAssignmentSystem/pkg/db/redis"
	"fmt"
	"reflect"
)

func RemoveRedisKeys(key string) {
	keysMatch, _ := redis.RedisGClient.Do("keys", fmt.Sprintf("%s_*", key)).Result()
	if reflect.TypeOf(keysMatch).Kind() == reflect.Slice {
		val := reflect.ValueOf(keysMatch)

		// 一个个删除这些key
		for i := 0; i < val.Len(); i++ {
			//fmt.Println(val.)
			redis.RedisGClient.Del(val.Index(i).Interface().(string))
		}
	}
}
